<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>

<form:form commandName="departMent" cssClass="form-horizontal" role="form">
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="deptName_edit">单位名称</label>
        <div class="col-sm-4">
            <input type="text" autocomplete='off' placeholder="必填" name="deptName" id="deptName_edit"
                   value="<c:out value="${departMent.deptName}"/>"
                   class="form-control " title="<c:out value="${departMent.deptName}"/>" required/>
        </div>
        <label class="col-sm-1 control-label no-padding-right" for="typeName_select">单位类型</label>
        <div class="col-sm-4">
            <select class="form-control" name="deptType" id="typeName_select">
                <option value="">选择单位类型（必填）</option>
                <option value="0">业主单位</option>
                <option value="1">审批单位</option>
                <option value="4">督查组</option>
                <option value="2">其他</option>
            </select>
        </div>
    </div>
    <%--<div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="address_create">地址</label>
        <div class="col-sm-4">
            <input type="password" autocomplete='off' placeholder="非必填" name="address" id="address_create"
                   class="form-control"/>
        </div>
        <label class="col-sm-1 control-label no-padding-right" for="remarks_create">备注</label>
        <div class="col-sm-4">
            <input type="password" autocomplete='off' placeholder="非必填" name="remarks" id="remarks_create"
                   class="form-control"/>
        </div>
    </div>--%>
    <form:hidden path="sysId"/>
</form:form>
<script>
    $(function () {
        $("#deptName_edit").blur(function () {
            debugger;
            var deptName = $("#deptName_edit").val();
            var deptName_old = '${departMent.deptName}';
            $.ajax({
                type: "GET",
                url: "/api/department/queryDeptNameExist",
                dataType: "json",
                data: {deptName: deptName},
                success: function (model) {
                    if (model.code == "1" && deptName_old != deptName) {
                        alert("单位:‘" + deptName + "’系统已存在，不需要重新添加！");
                        $("#deptName_edit").val(deptName_old);
                    }
                },
                error: function (model) {
                }
            });
        })
        var deptType = ${departMent.deptType};
        $("#typeName_select").val(deptType);
    })
</script>